#include "SMG.h"

sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;

uchar code smgduan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,
                   0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};
								 
void SMG_delay(uint i)
{
	while(i--);
}

void DigDisplay(uchar place,uchar number)
{
	switch(place)
	{
		case 8:
					LSA=0;LSB=0;LSC=0; break;
		case 7:
					LSA=1;LSB=0;LSC=0; break;
		case 6:
					LSA=0;LSB=1;LSC=0; break;
		case 5:
					LSA=1;LSB=1;LSC=0; break;
		case 4:
					LSA=0;LSB=0;LSC=1; break;
		case 3:
					LSA=1;LSB=0;LSC=1; break;
		case 2:
					LSA=0;LSB=1;LSC=1; break;
		case 1:
					LSA=1;LSB=1;LSC=1; break;
	}
	P0=smgduan[number];
	SMG_delay(100);
	P0=0X00;
}

void DispalyLow(int number)
{
	DigDisplay(5,number/1000%10);
	DigDisplay(6,number/100%10);
	DigDisplay(7,number/10%10);
	DigDisplay(8,number%10);
}
void DispalyHigh(int number)
{
	DigDisplay(1,number/1000%10);
	DigDisplay(2,number/100%10);
	DigDisplay(3,number/10%10);
	DigDisplay(4,number%10);
}
void DisplayAll(long number)
{
	DigDisplay(1,number/10000000%10);
	DigDisplay(2,number/1000000%10);
	DigDisplay(3,number/100000%10);
	DigDisplay(4,number/10000%10);
	DigDisplay(5,number/1000%10);
	DigDisplay(6,number/100%10);
	DigDisplay(7,number/10%10);
	DigDisplay(8,number%10);
}